define([
        'app/utils/WebUtils',
        'app/utils/WeixinUtils',
        'text!app/tpl/roomManage.html',
        'app/service/RoomService',
        'app/directive/ManageRoomDirective'
        
        ], function (
        WebUtils,
        WeixinUtils,
        roomManageTpl,
        RoomService,
        ManageRoomDirective
    ) {

    

    var controller = function (roomUuid) {

        //0. Weixin Disabled
        WeixinUtils.disableAll();

        
        //1. Data Initialized
        RoomService.getRoomDetails(roomUuid, function(resp){
            
            if($.isNull(resp)){
                $.redirectTo($.wjtBaseBackend + "/mvc/authorize?state=login");
                return;
            }

            if(resp.status!="200"){
                $.redirectTo($.wjtBaseBackend + "/mvc/authorize?state=login");
                return;
            }

            console.log(resp);

            //2. Weixin Initialized
            WeixinUtils.disableAll();


            //3. tpl Initialized - Never change!!!
            var tpl = WebUtils.tplInitialized();

            //4. UI Initialized
            var roomManageUI = _.template(roomManageTpl)({
                "ratio": resp.result.ratio,
                "name": resp.result.name,
                "starttime": $.timeFormat(resp.result.starttime),
                "des": resp.result.des,
                "thumburl": resp.result.thumburl,
                "uuid": resp.result.uuid,
                "status": resp.result.status,
                "lecturePages": resp.result.lecturePages
            });
           

            //4. Assemble
            tpl.append(roomManageUI);

            //5. Render - Never change!!!
            WebUtils.render(tpl);

            //6. Directive initialized
            ManageRoomDirective.directive_addNewResource();
            ManageRoomDirective.directive_closeit();
            ManageRoomDirective.directive_orderButton();
            ManageRoomDirective.directive_pptMoreOperation();
            // ManageRoomDirective.


        })
        


        //7. routechange - Never change!!!
        controller.onRouteChange = WebUtils.routeChange;

    };

    return controller;


});










define([
        'app/utils/WebUtils',
        'app/utils/WeixinUtils',
        'text!app/tpl/roomManage.html'
        
        ], function (
        WebUtils,
        WeixinUtils,
        roomManageTpl
    ) {

    

    var controller = function (sn) {
        
        //1. Data Initialized

        
        //2. Weixin Initialized
        WeixinUtils.disableAll();


        //3. UI Initialized
        appView.html("");
       
       
       //4. Assemble & Render
        appView.append(roomManageTpl);
   
 
        //5. Directive initialized;




        //6. routechange
        controller.onRouteChange = WebUtils.routeChange;

    };

    return controller;


});
